package cn.com.elite;

import java.util.List;

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

public class SanBean {
	private static final Log log=LogFactory.getLog(SanBean.class);
	 private DataSource dataSource;
	 private DataSourceTransactionManager tran;
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	public DataSourceTransactionManager getTran() {
		return tran;
	}
	public void setTran(DataSourceTransactionManager tran) {
		this.tran = tran;
	}
	 
	public List chaxun(String sql){
		try{
			log.info("sql:"+sql);
			JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
			List resultList = jdbcTemplate.queryForList(sql);
			return resultList;
		}catch(Exception e){
			log.error("chaxun:"+e.toString());
			return null;
		}
	}

}
